<?php

namespace app\admin\model\xilumarket\configuration;

use think\Model;
use traits\model\SoftDelete;

class Area extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'xilumarket_area';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'level_text',
        'is_re_text',
        'status_text'
    ];
    

    
    public function getLevelList()
    {
        return ['1' => __('Level 1'), '2' => __('Level 2'), '3' => __('Level 3'), '4' => __('Level 4')];
    }

    public function getIsReList()
    {
        return ['1' => __('Is_re 1'), '2' => __('Is_re 2')];
    }

    public function getStatusList()
    {
        return ['normal' => __('Status normal'), 'hidden' => __('Status hidden')];
    }


    public function getLevelTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['level']) ? $data['level'] : '');
        $list = $this->getLevelList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsReTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_re']) ? $data['is_re'] : '');
        $list = $this->getIsReList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
